package com.woniuxy.thred;

/**
 * description: StaticProxy <br>
 * date: 2022/2/5 4:02 下午 <br>
 * author: shesaifei <br>
 * version: 1.0 <br>
 */

/**
 * 静态代理
 * 接口：
 * 1、真实角色
 * 2、代理角色
 */

public class StaticProxy {
    public static void main(String[] args) {
        new weddingCompany(new You()).happMary();
    }
}

interface Marry {
    void happMary();

}

//真实角色
class You implements Marry {
    @Override
    public void happMary() {
        System.out.println("在一起了");
    }
}

//代理角色
class weddingCompany implements Marry {
    //真实角色
    private Marry target;

    public weddingCompany(Marry target) {
        this.target = target;
    }

    @Override
    public void happMary() {
        read();
        this.target.happMary();
        after();
    }


    private void read() {
        System.out.println("布置房间");
    }

    private void after() {
        System.out.println("闹洞房！");
    }
}